import React, { Component } from 'react';
import { Form, Select, Input, Button, Modal } from 'antd';
const FormItem = Form.Item;
const Option = Select.Option;
const { TextArea } = Input;

class PopForm2 extends Component {
  constructor(props) {
    super(props);
    this.state = {
      // Form:form
    };
  }
    formValidate= () => {
      console.log(2);
      this.props.form.validateFields((err, values) => {
        if (err) {
          console.log('err');
          return;
        }
        this.props.onCreate(values);
        this.props.form.resetFields();
      });
    }
    render() {
      const { visible, onCancel, onCreate, form, infor } = this.props;
      const { getFieldDecorator } = form;
      const aaa = this.props.infor ? this.props.infor : {};
      return (
        <Modal
          visible={visible}
          title="编辑"
          okText="确定"
          cancelText="取消"
          onCancel={onCancel}
          onOk={this.formValidate}
        >
          <Form>
            <FormItem
              label="name"
              labelCol={{ span: 5 }}
              wrapperCol={{ span: 16 }}
            >
              {getFieldDecorator('templateName', {
                rules: [{ required: true, message: '请输入请输入ChaincodeName!', }],
                initialValue: aaa.templateName
              })(
                <Input placeholder="请输入请输入ChaincodeName" />
              )}
            </FormItem>
            <FormItem
              label="模板描述："
              labelCol={{ span: 5 }}
              wrapperCol={{ span: 16 }}
            >
              {getFieldDecorator('remark', {
                rules: [{ required: true, message: '请输入内容!', }],
                initialValue: aaa.remark
              })(
                <TextArea rows={4} />
              )}
            </FormItem>
          </Form>
        </Modal>
      );
    }

}
const EditForm = Form.create()(PopForm2);
export default EditForm;